package com.lyz.jingjie;

import java.util.Scanner;

/**
 * @ClassName ExceptionTest
 * @Description 异常
 * @Author 2214361854
 * @Date 2022/2/23 16:42
 * @Version 1.0
 */
public class ExceptionTest {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (true) {
            try {
                System.out.println("请输入合法的价格：");
                String priceStr = sc.nextLine();
                double price = Double.valueOf(priceStr);
                if (price > 0) {
                    System.out.println("定价："+price);
                    break;
                }else {
                    System.out.println("价格必须是正数~~~~");
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }
}
